package com.anolesoft.yr.util;

import com.anolesoft.yr.mbus.base.dto.BaseAddressBookDTO;
import com.anolesoft.yr.mbus.base.dto.BaseCompanyDTO;
import com.anolesoft.yr.mbus.base.dto.BaseContactDTO;
import com.anolesoft.yr.mbus.base.dto.BaseRegionDTO;
import com.anolesoft.yr.mbus.base.entity.BaseAddressBookDO;
import com.anolesoft.yr.mbus.base.entity.BaseCompanyDO;
import com.anolesoft.yr.mbus.base.entity.BaseContactDO;
import com.anolesoft.yr.mbus.base.entity.BaseRegionDO;
import com.anolesoft.yr.mbus.base.vo.BaseCompanyVO;
import com.anolesoft.yr.mbus.base.vo.BaseContactVO;
import com.anolesoft.yr.mbus.base.vo.BaseRegionVO;
import com.anolesoft.yr.mbus.code.dto.CodeItemDTO;
import com.anolesoft.yr.mbus.code.dto.CodeItemRelDTO;
import com.anolesoft.yr.mbus.code.dto.CodeMainDTO;
import com.anolesoft.yr.mbus.code.entity.CodeItemDO;
import com.anolesoft.yr.mbus.code.entity.CodeItemRelDO;
import com.anolesoft.yr.mbus.code.entity.CodeMainDO;
import com.anolesoft.yr.mbus.code.vo.CodeItemRelVO;
import com.anolesoft.yr.mbus.code.vo.CodeItemVO;
import com.anolesoft.yr.mbus.code.vo.CodeMainVO;
import com.anolesoft.yr.mbus.crm.dto.CrmBaseDTO;
import com.anolesoft.yr.mbus.crm.dto.CrmBasePartPriceDTO;
import com.anolesoft.yr.mbus.crm.dto.CrmBasePartPriceQueryDTO;
import com.anolesoft.yr.mbus.crm.entity.CrmBaseDO;
import com.anolesoft.yr.mbus.crm.entity.CrmBasePartPriceDO;
import com.anolesoft.yr.mbus.crm.entity.CrmBasePartPriceQueryDO;
import com.anolesoft.yr.mbus.crm.vo.CrmBasePartPriceQueryVO;
import com.anolesoft.yr.mbus.crm.vo.CrmBasePartPriceVO;
import com.anolesoft.yr.mbus.crm.vo.CrmBaseVO;
import com.anolesoft.yr.mbus.fin.dto.FinBillingApplyDTO;
import com.anolesoft.yr.mbus.fin.dto.FinBillingApplyInvoiceDTO;
import com.anolesoft.yr.mbus.fin.entity.FinBillingApplyDO;
import com.anolesoft.yr.mbus.fin.vo.FinBillingApplyInvoiceVO;
import com.anolesoft.yr.mbus.fin.vo.FinBillingApplyVO;
import com.anolesoft.yr.mbus.part.dto.PartBomDTO;
import com.anolesoft.yr.mbus.part.dto.PartModelDTO;
import com.anolesoft.yr.mbus.part.dto.PartSafetyQuantityDTO;
import com.anolesoft.yr.mbus.part.dto.PartTypeDTO;
import com.anolesoft.yr.mbus.part.entity.PartBomDO;
import com.anolesoft.yr.mbus.part.entity.PartModelDO;
import com.anolesoft.yr.mbus.part.entity.PartSafetyQuantityDO;
import com.anolesoft.yr.mbus.part.entity.PartTypeDO;
import com.anolesoft.yr.mbus.part.vo.PartBomVO;
import com.anolesoft.yr.mbus.part.vo.PartModelVO;
import com.anolesoft.yr.mbus.part.vo.PartSafetyQuantityVO;
import com.anolesoft.yr.mbus.part.vo.PartTypeVO;
import com.anolesoft.yr.mbus.sup.dto.SupBaseDTO;
import com.anolesoft.yr.mbus.sup.dto.SupBasePartDTO;
import com.anolesoft.yr.mbus.sup.dto.SupBasePartPriceDTO;
import com.anolesoft.yr.mbus.sup.entity.SupBaseDO;
import com.anolesoft.yr.mbus.sup.entity.SupBasePartDO;
import com.anolesoft.yr.mbus.sup.entity.SupBasePartPriceDO;
import com.anolesoft.yr.mbus.sup.vo.SupBasePartPriceVO;
import com.anolesoft.yr.mbus.sup.vo.SupBasePartVO;
import com.anolesoft.yr.mbus.sup.vo.SupBaseVO;
import com.anolesoft.yr.store.stk.dto.StkMainDTO;
import com.anolesoft.yr.store.stk.dto.StkTypeDTO;
import com.anolesoft.yr.store.stk.entity.StkMain;
import com.anolesoft.yr.store.stk.entity.StkType;
import com.anolesoft.yr.store.stk.vo.StkMainVO;
import com.anolesoft.yr.store.stk.vo.StkTypeVO;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhj
 * @date 2020/8/11 20:07
 */
public final class CustomBeanUtils {
    private CustomBeanUtils() {

    }

    public static BaseRegionDTO baseRegionDO2DTO(BaseRegionDO t) {
        if (t == null) {
            return null;
        }
        return BaseRegionDTO.builder()
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .factoryCode(t.getFactoryCode())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .parentUid(t.getParentUid())
                .regionCode(t.getRegionCode())
                .regionLevel(t.getRegionLevel())
                .regionName(t.getRegionName())
                .remark(t.getRemark())
                .build();
    }

    public static BaseRegionVO baseRegionDTO2VO(BaseRegionDTO t) {
        if (t == null) {
            return null;
        }
        return BaseRegionVO.builder()
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .factoryCode(t.getFactoryCode())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .parentUid(t.getParentUid() == null ? "-" : t.getParentUid())
                .regionCode(t.getRegionCode())
                .regionLevel(t.getRegionLevel())
                .regionName(t.getRegionName())
                .remark(t.getRemark())
                .build();
    }

    public static BaseContactDTO baseContactDO2DTO(BaseContactDO t) {
        if (t == null) {
            return null;
        }
        return BaseContactDTO.builder()
                .contactNumber(t.getContactNumber())
                .contactPerson(t.getContactPerson())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .crmAddress(t.getCrmAddress())
                .deleteFlag(t.getDeleteFlag())
                .factoryCode(t.getFactoryCode())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .postcode(t.getPostcode())
                .remark(t.getRemark())
                .targetUid(t.getTargetUid())
                .type(t.getType())
                .build();
    }

    public static BaseContactVO baseContactDTO2VO(BaseContactDTO t) {
        if (t == null) {
            return null;
        }
        return BaseContactVO.builder()
                .contactNumber(t.getContactNumber())
                .contactPerson(t.getContactPerson())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .crmAddress(t.getCrmAddress())
                .deleteFlag(t.getDeleteFlag())
                .factoryCode(t.getFactoryCode())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .postcode(t.getPostcode())
                .remark(t.getRemark())
                .targetUid(t.getTargetUid())
                .type(t.getType())
                .build();
    }

    public static BaseAddressBookDTO baseAddressBookDO2DTO(BaseAddressBookDO t) {
        if (t == null) {
            return null;
        }
        return BaseAddressBookDTO.builder()
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .dept(t.getDept())
                .email(t.getEmail())
                .factoryCode(t.getFactoryCode())
                .modifyUserUid(t.getModifyUserUid())
                .name(t.getName())
                .objuid(t.getObjuid())
                .phone(t.getPhone())
                .post(t.getPost())
                .remark(t.getRemark())
                .targetUid(t.getTargetUid())
                .type(t.getType())
                .build();
    }

    public static BaseCompanyDTO baseCompanyDO2DTO(BaseCompanyDO t) {
        if (t == null) {
            return null;
        }
        BaseRegionDTO baseRegionDTO = baseRegionDO2DTO(t.getRegion());

        List<BaseContactDTO> baseContactDOTS = new ArrayList<>(10);
        final List<BaseContactDO> contacts = t.getContacts();
        if (t.getContacts() != null) {
            List<BaseContactDTO> collect = contacts.stream().map(t1 -> baseContactDO2DTO(t1)).collect(Collectors.toList());
            baseContactDOTS.addAll(collect);
        }

        return BaseCompanyDTO.builder()
                .account(t.getAccount())
                .bank(t.getBank())
                .baseRegionUid(t.getBaseRegionUid())
                .companyAddress(t.getCompanyAddress())
                .companyCode(t.getCompanyCode())
                .companyGrade(t.getCompanyGrade())
                .companyName(t.getCompanyName())
                .companyOtherName(t.getCompanyOtherName())
                .companyType(t.getCompanyType())
                .companyWebsite(t.getCompanyWebsite())
                .contactNumber(t.getContactNumber())
                .contactPerson(t.getContactPerson())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .email(t.getEmail())
                .establishTime(t.getEstablishTime())
                .factoryCode(t.getFactoryCode())
                .faxNumber(t.getFaxNumber())
                .legalPerson(t.getLegalPerson())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .region(baseRegionDTO)
                .remark(t.getRemark())
                .taxNumber(t.getTaxNumber())
                .contacts(baseContactDOTS)
                .build();
    }

    public static BaseCompanyVO baseCompanyDTO2VO(BaseCompanyDTO t) {
        if (t == null) {
            return null;
        }
        BaseRegionVO baseRegionVO = baseRegionDTO2VO(t.getRegion());

        List<BaseContactVO> baseContactVOS = new ArrayList<>(10);
        final List<BaseContactDTO> contacts = t.getContacts();
        if (t.getContacts() != null) {
            List<BaseContactVO> collect = contacts.stream().map(t1 -> baseContactDTO2VO(t1)).collect(Collectors.toList());
            baseContactVOS.addAll(collect);
        }

        return BaseCompanyVO.builder()
                .account(t.getAccount())
                .bank(t.getBank())
                .baseRegionUid(t.getBaseRegionUid())
                .companyAddress(t.getCompanyAddress())
                .companyCode(t.getCompanyCode())
                .companyGrade(t.getCompanyGrade())
                .companyName(t.getCompanyName())
                .companyOtherName(t.getCompanyOtherName())
                .companyType(t.getCompanyType())
                .companyWebsite(t.getCompanyWebsite())
                .contactNumber(t.getContactNumber())
                .contactPerson(t.getContactPerson())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .email(t.getEmail())
                .establishTime(t.getEstablishTime())
                .factoryCode(t.getFactoryCode())
                .faxNumber(t.getFaxNumber())
                .legalPerson(t.getLegalPerson())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .region(baseRegionVO)
                .remark(t.getRemark())
                .taxNumber(t.getTaxNumber())
                .contacts(baseContactVOS)
                .regionName(t.getRegion() == null ? null : t.getRegion().getRegionName())
                .build();
    }

    public static CodeMainDTO codeMainDO2DTO(CodeMainDO t){
        if (t==null) {
            return null;
        }
        List<CodeItemRelDO> codeItemRels = t.getCodeItemRels();
        List<CodeItemRelDTO> codeItemRelDTOS = new ArrayList<>(10);
        if(codeItemRels!=null){
            codeItemRelDTOS.addAll(codeItemRels.stream().map(CustomBeanUtils::codeItemRelDO2DTO).collect(Collectors.toList()));
        }
        return CodeMainDTO.builder()
                .codeDesc(t.getCodeDesc())
                .codeName(t.getCodeName())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .factoryCode(t.getFactoryCode())
                .geneClass(t.getGeneClass())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .remark(t.getRemark())
                .codeItemRels(codeItemRelDTOS)
                .build();
    }
    public static CodeMainVO codeMainDTO2VO(CodeMainDTO t){
        if (t==null) {
            return null;
        }
        return CodeMainVO.builder()
                .codeDesc(t.getCodeDesc())
                .codeName(t.getCodeName())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .factoryCode(t.getFactoryCode())
                .geneClass(t.getGeneClass())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .remark(t.getRemark())
                .build();
    }


    public static CodeItemDTO codeItemDO2DTO(CodeItemDO t){
        if(t == null){
            return null;
        }
        return CodeItemDTO.builder()
                .itemCodeName(t.getItemCodeName())
                .objuid(t.getObjuid())
                .factoryCode(t.getFactoryCode())
                .trimAspect(t.getTrimAspect())
                .remark(t.getRemark())
                .modifyUserUid(t.getModifyUserUid())
                .modifyTime(t.getModifyTime())
                .itemType(t.getItemType())
                .itemPlaceholder(t.getItemPlaceholder())
                .itemLength(t.getItemLength())
                .itemGeneClass(t.getItemGeneClass())
                .itemFormat(t.getItemFormat())
                .itemDesc(t.getItemDesc())
                .deleteFlag(t.getDeleteFlag())
                .createUserUid(t.getCreateUserUid())
                .createTime(t.getCreateTime())
                .build();
    }
    public static CodeItemVO codeItemDTO2VO(CodeItemDTO t){
        if(t == null){
            return null;
        }
        return CodeItemVO.builder()
                .itemCodeName(t.getItemCodeName())
                .objuid(t.getObjuid())
                .factoryCode(t.getFactoryCode())
                .trimAspect(t.getTrimAspect())
                .remark(t.getRemark())
                .modifyUserUid(t.getModifyUserUid())
                .modifyTime(t.getModifyTime())
                .itemType(t.getItemType())
                .itemPlaceholder(t.getItemPlaceholder())
                .itemLength(t.getItemLength())
                .itemGeneClass(t.getItemGeneClass())
                .itemFormat(t.getItemFormat())
                .itemDesc(t.getItemDesc())
                .deleteFlag(t.getDeleteFlag())
                .createUserUid(t.getCreateUserUid())
                .createTime(t.getCreateTime())
                .build();
    }

    public static CodeItemRelDTO codeItemRelDO2DTO(CodeItemRelDO t){
        if(t == null){
            return null;
        }
        CodeItemDO codeItem = t.getCodeItem();
        return CodeItemRelDTO.builder()
                .remark(t.getRemark())
                .orderNum(t.getOrderNum())
                .objuid(t.getObjuid())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .factoryCode(t.getFactoryCode())
                .deleteFlag(t.getDeleteFlag())
                .createUserUid(t.getCreateUserUid())
                .createTime(t.getCreateTime())
                .codeMainUid(t.getCodeMainUid())
                .codeItemUid(t.getCodeItemUid())
                .codeItem(codeItemDO2DTO(codeItem))
                .build();
    }
    public static CodeItemRelVO codeItemRelDTO2VO(CodeItemRelDTO t){
        if(t == null){
            return null;
        }
        CodeItemDTO codeItem = t.getCodeItem();
        return CodeItemRelVO.builder()
                .remark(t.getRemark())
                .orderNum(t.getOrderNum())
                .objuid(t.getObjuid())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .factoryCode(t.getFactoryCode())
                .deleteFlag(t.getDeleteFlag())
                .createUserUid(t.getCreateUserUid())
                .createTime(t.getCreateTime())
                .codeMainUid(t.getCodeMainUid())
                .codeItemUid(t.getCodeItemUid())
                .codeItem(codeItemDTO2VO(codeItem))
                .build();
    }

    public static CrmBaseDTO crmBaseDO2DTO(CrmBaseDO t) {
        if (t == null) {
            return null;
        }
        BaseRegionDTO baseRegionDTO = baseRegionDO2DTO(t.getRegion());
        List<BaseContactDTO> baseContactDOTS = new ArrayList<>(10);
        List<BaseContactDO> contacts = t.getContacts();
        if (contacts != null) {
            List<BaseContactDTO> collect = contacts.stream().map(t1 -> baseContactDO2DTO(t1)).collect(Collectors.toList());
            baseContactDOTS.addAll(collect);
        }

        return CrmBaseDTO.builder()
                .account(t.getAccount())
                .bank(t.getBank())
                .baseRegionUid(t.getBaseRegionUid())
                .crmAddress(t.getCrmAddress())
                .crmCode(t.getCrmCode())
                .crmGrade(t.getCrmGrade())
                .crmName(t.getCrmName())
                .crmOtherName(t.getCrmOtherName())
                .companyType(t.getCompanyType())
                .crmWebsite(t.getCrmWebsite())
                .contactNumber(t.getContactNumber())
                .contactPerson(t.getContactPerson())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .email(t.getEmail())
                .establishTime(t.getEstablishTime())
                .factoryCode(t.getFactoryCode())
                .faxNumber(t.getFaxNumber())
                .legalPerson(t.getLegalPerson())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .region(baseRegionDTO)
                .remark(t.getRemark())
                .taxNumber(t.getTaxNumber())
                .contacts(baseContactDOTS)
                .build();
    }

    public static CrmBaseVO crmBaseDTO2VO(CrmBaseDTO t) {
        if (t == null) {
            return null;
        }
        BaseRegionVO baseRegionVO = baseRegionDTO2VO(t.getRegion());
        List<BaseContactVO> baseContactVOS = new ArrayList<>(10);
        List<BaseContactDTO> contacts = t.getContacts();
        if (contacts != null) {
            List<BaseContactVO> collect = contacts.stream().map(t1 -> baseContactDTO2VO(t1)).collect(Collectors.toList());
            baseContactVOS.addAll(collect);
        }
        return CrmBaseVO.builder()
                .account(t.getAccount())
                .bank(t.getBank())
                .baseRegionUid(t.getBaseRegionUid())
                .crmAddress(t.getCrmAddress())
                .crmCode(t.getCrmCode())
                .crmGrade(t.getCrmGrade())
                .crmName(t.getCrmName())
                .crmOtherName(t.getCrmOtherName())
                .companyType(t.getCompanyType())
                .crmWebsite(t.getCrmWebsite())
                .contactNumber(t.getContactNumber())
                .contactPerson(t.getContactPerson())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .email(t.getEmail())
                .establishTime(t.getEstablishTime())
                .factoryCode(t.getFactoryCode())
                .faxNumber(t.getFaxNumber())
                .legalPerson(t.getLegalPerson())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .region(baseRegionVO)
                .remark(t.getRemark())
                .taxNumber(t.getTaxNumber())
                .contacts(baseContactVOS)
                .regionName(t.getRegion() == null ? null : t.getRegion().getRegionName())
                .build();
    }

    public static CrmBasePartPriceVO crmBasePartPriceDTO2VO(CrmBasePartPriceDTO t) {
        if (t == null) {
            return null;
        } else {
            CrmBaseVO crmBaseVO = crmBaseDTO2VO(t.getCrmBase());
            PartModelVO partModel = partModelDTO2VO(t.getPartModel());
            return CrmBasePartPriceVO.builder()
                    .partModelUid(t.getPartModelUid())
                    .createTime(t.getCreateTime())
                    .createUserUid(t.getCreateUserUid())
                    .crmBaseUid(t.getCrmBaseUid())
                    .contMainUid(t.getContMainUid())
                    .preOrderUid(t.getPreOrderUid())
                    .prodProductUid(t.getProdProductUid())
//                    .dealPrice(t.getDealPrice())
                    .deleteFlag(t.getDeleteFlag())
                    .factoryCode(t.getFactoryCode())
                    .modifyTime(t.getModifyTime())
                    .modifyUserUid(t.getModifyUserUid())
                    .objuid(t.getObjuid())
                    .offerPerson(t.getOfferPerson())
                    .offerPrice(t.getOfferPrice())
                    .offerTime(t.getOfferTime())
                    .remark(t.getRemark())
                    .crmBase(crmBaseVO)
                    .crmName(crmBaseVO == null ? null : crmBaseVO.getCrmName())
                    .partModel(partModel)
                    .build();
        }
    }

    public static CrmBasePartPriceDTO crmBasePartPriceDO2DTO(CrmBasePartPriceDO t) {
        if (t == null) {
            return null;
        } else {
            CrmBaseDTO crmBaseDTO = crmBaseDO2DTO(t.getCrmBase());
            PartModelDTO partModel = partModelDO2DTO(t.getPartModel());
            return CrmBasePartPriceDTO.builder()
                    .contMainUid(t.getContMainUid())
                    .preOrderUid(t.getPreOrderUid())
                    .prodProductUid(t.getProdProductUid())
                    .partModelUid(t.getPartModelUid())
                    .createTime(t.getCreateTime())
                    .createUserUid(t.getCreateUserUid())
                    .crmBaseUid(t.getCrmBaseUid())
//                    .dealPrice(t.getDealPrice())
                    .deleteFlag(t.getDeleteFlag())
                    .factoryCode(t.getFactoryCode())
                    .modifyTime(t.getModifyTime())
                    .modifyUserUid(t.getModifyUserUid())
                    .objuid(t.getObjuid())
                    .offerPerson(t.getOfferPerson())
                    .offerPrice(t.getOfferPrice())
                    .offerTime(t.getOfferTime())
                    .remark(t.getRemark())
                    .crmBase(crmBaseDTO)
                    .partModel(partModel)
                    .build();
        }

    }

    public static CrmBasePartPriceQueryVO crmBasePartPriceQueryDTO2VO(CrmBasePartPriceQueryDTO t) {
        if (t == null) {
            return null;
        }
        return CrmBasePartPriceQueryVO.builder()
                .objuid(t.getObjuid())
                .contMainUid(t.getContMainUid())
                .preOrderUid(t.getPreOrderUid())
                .prodProductUid(t.getProdProductUid())
                .crmBaseUid(t.getCrmBaseUid())
                .partModelUid(t.getPartModelUid())
                .offerPerson(t.getOfferPerson())
                .offerTime(t.getOfferTime())
                .offerPrice(t.getOfferPrice())


                .bcrmCode(t.getBcrmCode())
                .bcrmName(t.getBcrmName())
                .bcrmOtherName(t.getBcrmOtherName())

                .cisTemp(t.getCisTemp())
                .ccontTypeUid(t.getCcontTypeUid())
                .csignDate(t.getCsignDate())
                .csignAddress(t.getCsignAddress())
                .ccontCode(t.getCcontCode())
                .ccustomerContractCode(t.getCcustomerContractCode())
                .cpayment(t.getCpayment())
                .ccontTitle(t.getCcontTitle())
                .c1Name(t.getC1Name())

                .dquotationCode(t.getDquotationCode())
                .dstate(t.getDstate())

                .eprodTypeUid(t.getEprodTypeUid())
                .eprodCode(t.getEprodCode())
                .eprodName(t.getEprodName())
                .e1typeCode(t.getE1typeCode())
                .e1typeName(t.getE1typeName())
                .e1typeNature(t.getE1typeNature())

                .fpartCode(t.getFpartCode())
                .fpartName(t.getFpartName())
                .fpartBrand(t.getFpartBrand())
                .fpartModel(t.getFpartModel())
                .fpartSpecification(t.getFpartSpecification())
                .fpartTypeUid(t.getFpartTypeUid())
                .fquantity(t.getFquantity())
                .f1typeCode(t.getF1typeCode())
                .f1typeName(t.getF1typeName())
                .build();
    }

    public static CrmBasePartPriceQueryDTO crmBasePartPriceQueryDO2DTO(CrmBasePartPriceQueryDO t) {
        if (t == null) {
            return null;
        }
        return CrmBasePartPriceQueryDTO.builder()
                .objuid(t.getObjuid())
                .contMainUid(t.getContMainUid())
                .preOrderUid(t.getPreOrderUid())
                .prodProductUid(t.getProdProductUid())
                .crmBaseUid(t.getCrmBaseUid())
                .partModelUid(t.getPartModelUid())
                .offerPerson(t.getOfferPerson())
                .offerTime(t.getOfferTime())
                .offerPrice(t.getOfferPrice())


                .bcrmCode(t.getBcrmCode())
                .bcrmName(t.getBcrmName())
                .bcrmOtherName(t.getBcrmOtherName())

                .cisTemp(t.getCisTemp())
                .ccontTypeUid(t.getCcontTypeUid())
                .csignDate(t.getCsignDate())
                .csignAddress(t.getCsignAddress())
                .ccontCode(t.getCcontCode())
                .ccustomerContractCode(t.getCcustomerContractCode())
                .cpayment(t.getCpayment())
                .ccontTitle(t.getCcontTitle())
                .c1Name(t.getC1Name())

                .dquotationCode(t.getDquotationCode())
                .dstate(t.getDstate())

                .eprodTypeUid(t.getEprodTypeUid())
                .eprodCode(t.getEprodCode())
                .eprodName(t.getEprodName())
                .e1typeCode(t.getE1typeCode())
                .e1typeName(t.getE1typeName())
                .e1typeNature(t.getE1typeNature())

                .eprodTypeUid(t.getEprodTypeUid())
                .eprodCode(t.getEprodCode())
                .eprodName(t.getEprodName())
                .e1typeCode(t.getE1typeCode())
                .e1typeName(t.getE1typeName())
                .e1typeNature(t.getE1typeNature())

                .fpartCode(t.getFpartCode())
                .fpartName(t.getFpartName())
                .fpartBrand(t.getFpartBrand())
                .fpartModel(t.getFpartModel())
                .fpartSpecification(t.getFpartSpecification())
                .fpartTypeUid(t.getFpartTypeUid())
                .fquantity(t.getFquantity())
                .f1typeCode(t.getF1typeCode())
                .f1typeName(t.getF1typeName())
                .build();
    }

    public static FinBillingApplyVO finBillingApplyDTO2VO(FinBillingApplyDTO dto) {
        if (dto == null) {
            return null;
        }
        return FinBillingApplyVO.builder()
                .amount(dto.getAmount())
                .billingCode(dto.getBillingCode())
                .contractCode(dto.getContractCode())
                .createTime(dto.getCreateTime())
                .createUserUid(dto.getCreateUserUid())
                .deleteFlag(dto.getDeleteFlag())
                .factoryCode(dto.getFactoryCode())
                .invoiceState(dto.getInvoiceState())
                .modifyTime(dto.getModifyTime())
                .modifyUserUid(dto.getModifyUserUid())
                .objuid(dto.getObjuid())
                .remark(dto.getRemark())
                .build();
    }

    public static FinBillingApplyDTO finBillingApplyDO2DTO(FinBillingApplyDO t) {
        if (t == null) {
            return null;
        }
        return FinBillingApplyDTO.builder()
                .amount(t.getAmount())
                .billingCode(t.getBillingCode())
                .contractCode(t.getContractCode())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .factoryCode(t.getFactoryCode())
                .invoiceState(t.getInvoiceState())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .remark(t.getRemark())
                .build();
    }

    public static FinBillingApplyInvoiceVO finBillingApplyInvoiceDTO2VO(FinBillingApplyInvoiceDTO dto) {
        if (dto != null) {
            FinBillingApplyVO finBillingApplyVO = finBillingApplyDTO2VO(dto.getBillingApply());

            return FinBillingApplyInvoiceVO.builder()
                    .invoiceCode(dto.getInvoiceCode())
                    .receiptCode(dto.getReceiptCode())
                    .factoryCode(dto.getFactoryCode())
                    .remark(dto.getRemark())
                    .objuid(dto.getObjuid())
                    .modifyUserUid(dto.getModifyUserUid())
                    .deleteFlag(dto.getDeleteFlag())
                    .createUserUid(dto.getCreateUserUid())
                    .createTime(dto.getCreateTime())
                    .amount(dto.getAmount())
                    .finBillingApplyUid(dto.getFinBillingApplyUid())
                    .modifyTime(dto.getModifyTime())
                    .billingApply(finBillingApplyVO)
                    .build();
        } else {
            return null;
        }
    }

    public static PartBomDTO partBomDO2DTO(PartBomDO t) {
        if (t == null) {
            return null;
        } else {

            PartModelDTO parentPartModelDTO = partModelDO2DTO(t.getParentPartModel());
            PartModelDTO partModelDTO = partModelDO2DTO(t.getPartModel());

            return PartBomDTO.builder()
                    .createTime(t.getCreateTime())
                    .createUserUid(t.getCreateUserUid())
                    .deleteFlag(t.getDeleteFlag())
                    .factoryCode(t.getFactoryCode())
                    .modifyTime(t.getModifyTime())
                    .modifyUserUid(t.getModifyUserUid())
                    .objuid(t.getObjuid())
                    .parentPartModelUid(t.getParentPartModelUid())
                    .partModelUid(t.getPartModelUid())
                    .quantity(t.getQuantity())
                    .remark(t.getRemark())
                    .parentPartModel(parentPartModelDTO)
                    .partModel(partModelDTO)
                    .build();
        }
    }

    public static PartBomVO partBomDTO2VO(PartBomDTO t) {
        if (t == null) {
            return null;
        } else {
            PartModelVO parentPartModel = partModelDTO2VO(t.getParentPartModel());
            PartModelVO partModel = partModelDTO2VO(t.getPartModel());
            return PartBomVO.builder()
                    .createTime(t.getCreateTime())
                    .createUserUid(t.getCreateUserUid())
                    .deleteFlag(t.getDeleteFlag())
                    .factoryCode(t.getFactoryCode())
                    .modifyTime(t.getModifyTime())
                    .modifyUserUid(t.getModifyUserUid())
                    .objuid(t.getObjuid())
                    .parentPartModelUid(t.getParentPartModelUid())
                    .partModelUid(t.getPartModelUid())
                    .quantity(t.getQuantity())
                    .remark(t.getRemark())
                    .parentPartModel(parentPartModel)
                    .partModel(partModel)
                    .build();
        }
    }

    public static PartModelVO partModelDTO2VO(PartModelDTO t) {
        if (t == null) {
            return null;
        } else {
            PartTypeVO partType = partTypeDTO2VO(t.getPartType());

            return PartModelVO.builder()
                    .createTime(t.getCreateTime())
                    .createUserUid(t.getCreateUserUid())
                    .deleteFlag(t.getDeleteFlag())
                    .factoryCode(t.getFactoryCode())
                    .modifyTime(t.getModifyTime())
                    .modifyUserUid(t.getModifyUserUid())
                    .objuid(t.getObjuid())
                    .partBrand(t.getPartBrand())
                    .partCode(t.getPartCode())
                    .partModel(t.getPartModel())
                    .viceModel(t.getViceModel())
                    .partName(t.getPartName())
                    .partSpecification(t.getPartSpecification())
                    .partTypeUid(t.getPartTypeUid())
                    .quantity(t.getQuantity())
                    .remark(t.getRemark())
                    .unit(t.getUnit())
                    .partType(partType)
                    .partTypeCode(partType == null ? null : partType.getTypeCode())
                    .partTypeName(partType == null ? null : partType.getTypeName())
                    .parentPartModelUid(t.getParentPartModelUid())
                    .build();
        }
    }

    public static PartModelDTO partModelDO2DTO(PartModelDO t) {
        if (t == null) {
            return null;
        } else {
            PartTypeDTO partType = partTypeDO2DTO(t.getPartType());

            return PartModelDTO.builder()
                    .createTime(t.getCreateTime())
                    .createUserUid(t.getCreateUserUid())
                    .deleteFlag(t.getDeleteFlag())
                    .factoryCode(t.getFactoryCode())
                    .modifyTime(t.getModifyTime())
                    .modifyUserUid(t.getModifyUserUid())
                    .objuid(t.getObjuid())
                    .partBrand(t.getPartBrand())
                    .partCode(t.getPartCode())
                    .partModel(t.getPartModel())
                    .viceModel(t.getViceModel())
                    .partName(t.getPartName())
                    .partSpecification(t.getPartSpecification())
                    .partTypeUid(t.getPartTypeUid())
                    .quantity(t.getQuantity())
                    .remark(t.getRemark())
                    .unit(t.getUnit())
                    .partType(partType)
                    .parentPartModelUid(t.getParentPartModelUid())
                    .build();
        }
    }

    public static PartTypeVO partTypeDTO2VO(PartTypeDTO t) {
        if (t == null) {
            return null;
        } else {
            return PartTypeVO.builder()
                    .typeCode(t.getTypeCode())
                    .typeName(t.getTypeName())
                    .remark(t.getRemark())
                    .objuid(t.getObjuid())
                    .modifyUserUid(t.getModifyUserUid())
                    .modifyTime(t.getModifyTime())
                    .factoryCode(t.getFactoryCode())
                    .deleteFlag(t.getDeleteFlag())
                    .createUserUid(t.getCreateUserUid())
                    .createTime(t.getCreateTime())
                    .build();
        }
    }

    public static PartTypeDTO partTypeDO2DTO(PartTypeDO t) {
        if (t == null) {
            return null;
        } else {
            return PartTypeDTO.builder()
                    .typeCode(t.getTypeCode())
                    .typeName(t.getTypeName())
                    .remark(t.getRemark())
                    .objuid(t.getObjuid())
                    .modifyUserUid(t.getModifyUserUid())
                    .modifyTime(t.getModifyTime())
                    .factoryCode(t.getFactoryCode())
                    .deleteFlag(t.getDeleteFlag())
                    .createUserUid(t.getCreateUserUid())
                    .createTime(t.getCreateTime())
                    .build();
        }
    }

    public static PartSafetyQuantityDTO partSafetyQuantityDO2DTO(PartSafetyQuantityDO t) {
        PartModelDTO partModelDTO = partModelDO2DTO(t.getPartModel());
        return PartSafetyQuantityDTO.builder()
                .objuid(t.getObjuid())
                .stkMainUid(t.getStkMainUid())
                .partModelUid(t.getPartModelUid())
                .factoryCode(t.getFactoryCode())
                .warningQuantity(t.getWarningQuantity())
                .remark(t.getRemark())
                .modifyUserUid(t.getModifyUserUid())
                .modifyTime(t.getModifyTime())
                .lowestReserve(t.getLowestReserve())
                .highestReserve(t.getHighestReserve())
                .deleteFlag(t.getDeleteFlag())
                .createUserUid(t.getCreateUserUid())
                .createTime(t.getCreateTime())
                .partModel(partModelDTO)
                .stkMain(stkMainDO2DTO(t.getStkMain()))
                .build();
    }

    public static PartSafetyQuantityVO partSafetyQuantityDTO2VO(PartSafetyQuantityDTO t) {
        PartModelVO partModelVO = partModelDTO2VO(t.getPartModel());
        return PartSafetyQuantityVO.builder()
                .objuid(t.getObjuid())
                .stkMainUid(t.getStkMainUid())
                .partModelUid(t.getPartModelUid())
                .factoryCode(t.getFactoryCode())
                .warningQuantity(t.getWarningQuantity())
                .remark(t.getRemark())
                .modifyUserUid(t.getModifyUserUid())
                .modifyTime(t.getModifyTime())
                .lowestReserve(t.getLowestReserve())
                .highestReserve(t.getHighestReserve())
                .deleteFlag(t.getDeleteFlag())
                .createUserUid(t.getCreateUserUid())
                .createTime(t.getCreateTime())
                .partModel(partModelVO)
                .stkMain(stkMainDTO2VO(t.getStkMain()))
                .build();
    }

//    public static PreOrderPartVO preOrderPartDTO2VO(PreOrderPartDTO t){
//        if(t == null){
//            return null;
//        }else{
//            CrmBasePartPriceVO crmBasePartPrice = crmBasePartPriceDTO2VO(t.getCrmBasePartPrice());
//            PartModelVO partModel = partModelDTO2VO(t.getPartModel());
//
//            return PreOrderPartVO.builder()
//                    .createTime(t.getCreateTime())
//                    .createUserUid(t.getCreateUserUid())
//                    .crmBasePartPriceUid(t.getCrmBasePartPriceUid())
//                    .deleteFlag(t.getDeleteFlag())
//                    .factoryCode(t.getFactoryCode())
//                    .inquiryPrice(t.getInquiryPrice())
//                    .isEffective(t.getIsEffective())
//                    .modifyTime(t.getModifyTime())
//                    .modifyUserUid(t.getModifyUserUid())
//                    .objuid(t.getObjuid())
//                    .offerPrice(t.getOfferPrice())
//                    .partModelUid(t.getPartModelUid())
//                    .preOrderUid(t.getPreOrderUid())
//                    .quantity(t.getQuantity())
//                    .remark(t.getRemark())
//                    .crmBasePartPrice(crmBasePartPrice)
//                    .partModel(partModel)
//                    .build();
//        }
//    }
//    public static PreOrderPartDTO preOrderPartDO2DTO(PreOrderPartDO t){
//        if(t == null){
//            return null;
//        }else{
//            CrmBasePartPriceDTO crmBasePartPrice = crmBasePartPriceDO2DTO(t.getCrmBasePartPrice());
//            PartModelDTO partModel = partModelDO2DTO(t.getPartModel());
//
//            return PreOrderPartDTO.builder()
//                    .createTime(t.getCreateTime())
//                    .createUserUid(t.getCreateUserUid())
//                    .crmBasePartPriceUid(t.getCrmBasePartPriceUid())
//                    .deleteFlag(t.getDeleteFlag())
//                    .factoryCode(t.getFactoryCode())
//                    .inquiryPrice(t.getInquiryPrice())
//                    .isEffective(t.getIsEffective())
//                    .modifyTime(t.getModifyTime())
//                    .modifyUserUid(t.getModifyUserUid())
//                    .objuid(t.getObjuid())
//                    .offerPrice(t.getOfferPrice())
//                    .partModelUid(t.getPartModelUid())
//                    .preOrderUid(t.getPreOrderUid())
//                    .quantity(t.getQuantity())
//                    .remark(t.getRemark())
//                    .crmBasePartPrice(crmBasePartPrice)
//                    .partModel(partModel)
//                    .build();
//        }
//    }
//    public static PreOrderServiceVO preOrderServiceDTO2VO(PreOrderServiceDTO t){
//        if (t==null) {
//            return null;
//        }else{
//            return PreOrderServiceVO.builder()
//                    .createTime(t.getCreateTime())
//                    .createUserUid(t.getCreateUserUid())
//                    .deleteFlag(t.getDeleteFlag())
//                    .factoryCode(t.getFactoryCode())
//                    .modifyTime(t.getModifyTime())
//                    .modifyUserUid(t.getModifyUserUid())
//                    .objuid(t.getObjuid())
//                    .preOrderUid(t.getPreOrderUid())
//                    .remark(t.getRemark())
//                    .serviceName(t.getServiceName())
//                    .serviceValue(t.getServiceValue())
//                    .build();
//        }
//    }
//    public static PreOrderServiceDTO preOrderServiceDO2DTO(PreOrderServiceDO t){
//        if (t==null) {
//            return null;
//        }else{
//            return PreOrderServiceDTO.builder()
//                    .createTime(t.getCreateTime())
//                    .createUserUid(t.getCreateUserUid())
//                    .deleteFlag(t.getDeleteFlag())
//                    .factoryCode(t.getFactoryCode())
//                    .modifyTime(t.getModifyTime())
//                    .modifyUserUid(t.getModifyUserUid())
//                    .objuid(t.getObjuid())
//                    .preOrderUid(t.getPreOrderUid())
//                    .remark(t.getRemark())
//                    .serviceName(t.getServiceName())
//                    .serviceValue(t.getServiceValue())
//                    .build();
//        }
//    }
//    public static PreOrderVO preOrderDTO2VO(PreOrderDTO t){
//        List<PreOrderServiceVO>  orderServices = new ArrayList<>(10);
//        List<PreOrderPartVO> orderParts = new ArrayList<>(10);
//
//        List<PreOrderServiceDTO> preOrderServiceDTOs = t.getPreOrderServices();
//        List<PreOrderPartDTO> preOrderPartDTOs = t.getPreOrderParts();
//        if (preOrderServiceDTOs!=null) {
//            List<PreOrderServiceVO> collect = preOrderServiceDTOs.stream().map(t1 -> preOrderServiceDTO2VO(t1)).collect(Collectors.toList());
//            orderServices.addAll(collect);
//        }
//        if (preOrderPartDTOs!=null) {
//            List<PreOrderPartVO> collect = preOrderPartDTOs.stream().map(t1 -> preOrderPartDTO2VO(t1)).collect(Collectors.toList());
//            orderParts.addAll(collect);
//        }
//        return PreOrderVO.builder()
//                .createTime(t.getCreateTime())
//                .createUserUid(t.getCreateUserUid())
//                .deleteFlag(t.getDeleteFlag())
//                .factoryCode(t.getFactoryCode())
//                .modifyTime(t.getModifyTime())
//                .modifyUserUid(t.getModifyUserUid())
//                .objuid(t.getObjuid())
//                .prePromoteUid(t.getPrePromoteUid())
//                .quotationCode(t.getQuotationCode())
//                .remark(t.getRemark())
//                .state(t.getState())
//                .preOrderParts(orderParts)
//                .preOrderServices(orderServices)
//                .build();
//    }
//    public static PreOrderDTO preOrderDO2DTO(PreOrderDO t) {
//
//        List<PreOrderServiceDTO>  orderServices = new ArrayList<>(10);
//        List<PreOrderPartDTO> orderParts = new ArrayList<>(10);
//
//        List<PreOrderServiceDO> preOrderServiceDOs = t.getPreOrderServices();
//        List<PreOrderPartDO> preOrderPartDOs = t.getPreOrderParts();
//        if (preOrderServiceDOs!=null) {
//            List<PreOrderServiceDTO> collect = preOrderServiceDOs.stream().map(t1 -> preOrderServiceDO2DTO(t1)).collect(Collectors.toList());
//            orderServices.addAll(collect);
//        }
//        if (preOrderPartDOs!=null) {
//            List<PreOrderPartDTO> collect = preOrderPartDOs.stream().map(t1 -> preOrderPartDO2DTO(t1)).collect(Collectors.toList());
//            orderParts.addAll(collect);
//        }
//        return PreOrderDTO.builder()
//                .createTime(t.getCreateTime())
//                .createUserUid(t.getCreateUserUid())
//                .deleteFlag(t.getDeleteFlag())
//                .factoryCode(t.getFactoryCode())
//                .modifyTime(t.getModifyTime())
//                .modifyUserUid(t.getModifyUserUid())
//                .objuid(t.getObjuid())
//                .prePromoteUid(t.getPrePromoteUid())
//                .quotationCode(t.getQuotationCode())
//                .remark(t.getRemark())
//                .state(t.getState())
//                .preOrderParts(orderParts)
//                .preOrderServices(orderServices)
//                .build();
//    }

    public static SupBasePartPriceDTO supBasePartPriceDO2DTO(SupBasePartPriceDO t) {
        if (t == null) {
            return null;
        }
        SupBasePartDTO supBasePartDTO = supBasePartDO2DTO(t.getSupBasePart());
        return SupBasePartPriceDTO.builder()
                .objuid(t.getObjuid())
                .offerPerson(t.getOfferPerson())
                .supBasePartUid(t.getSupBasePartUid())
                .factoryCode(t.getFactoryCode())
                .remark(t.getRemark())
                .offerTime(t.getOfferTime())
                .offerPrice(t.getOfferPrice())
                .modifyUserUid(t.getModifyUserUid())
                .modifyTime(t.getModifyTime())
                .deleteFlag(t.getDeleteFlag())
                .dealPrice(t.getDealPrice())
                .createUserUid(t.getCreateUserUid())
                .createTime(t.getCreateTime())
                .supBasePart(supBasePartDTO)
                .build();
    }

    public static SupBasePartPriceVO supBasePartPriceDTO2VO(SupBasePartPriceDTO t) {
        if (t == null) {
            return null;
        }
        SupBasePartVO supBasePartVO = supBasePartDTO2VO(t.getSupBasePart());
        return SupBasePartPriceVO.builder()
                .objuid(t.getObjuid())
                .offerPerson(t.getOfferPerson())
                .supBasePartUid(t.getSupBasePartUid())
                .factoryCode(t.getFactoryCode())
                .remark(t.getRemark())
                .offerTime(t.getOfferTime())
                .offerPrice(t.getOfferPrice())
                .modifyUserUid(t.getModifyUserUid())
                .modifyTime(t.getModifyTime())
                .deleteFlag(t.getDeleteFlag())
                .dealPrice(t.getDealPrice())
                .createUserUid(t.getCreateUserUid())
                .createTime(t.getCreateTime())
                .supBasePart(supBasePartVO)
                .build();
    }

    public static SupBaseDTO supBaseDO2DTO(SupBaseDO t) {
        if (t == null) {
            return null;
        }
        BaseRegionDTO baseRegionDTO = baseRegionDO2DTO(t.getRegion());
        List<BaseContactDTO> baseContactDOTS = new ArrayList<>(10);
        List<BaseContactDO> contacts = t.getContacts();
        if (contacts != null) {
            List<BaseContactDTO> collect = contacts.stream().map(t1 -> baseContactDO2DTO(t1)).collect(Collectors.toList());
            baseContactDOTS.addAll(collect);
        }
        return SupBaseDTO.builder()
                .account(t.getAccount())
                .bank(t.getBank())
                .baseRegionUid(t.getBaseRegionUid())
                .supAddress(t.getSupAddress())
                .supCode(t.getSupCode())
                .supGrade(t.getSupGrade())
                .supName(t.getSupName())
                .supOtherName(t.getSupOtherName())
                .companyType(t.getCompanyType())
                .supWebsite(t.getSupWebsite())
                .contactNumber(t.getContactNumber())
                .contactPerson(t.getContactPerson())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .email(t.getEmail())
                .establishTime(t.getEstablishTime())
                .factoryCode(t.getFactoryCode())
                .faxNumber(t.getFaxNumber())
                .legalPerson(t.getLegalPerson())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .region(baseRegionDTO)
                .remark(t.getRemark())
                .taxNumber(t.getTaxNumber())
                .contacts(baseContactDOTS)
                .build();
    }

    public static SupBaseVO supBaseDTO2VO(SupBaseDTO t) {
        if (t == null) {
            return null;
        }
        BaseRegionVO baseRegionDTO = baseRegionDTO2VO(t.getRegion());
        List<BaseContactVO> baseContactVOS = new ArrayList<>(10);
        List<BaseContactDTO> contacts = t.getContacts();
        if (contacts != null) {
            List<BaseContactVO> collect = contacts.stream().map(t1 -> baseContactDTO2VO(t1)).collect(Collectors.toList());
            baseContactVOS.addAll(collect);
        }
        return SupBaseVO.builder()
                .account(t.getAccount())
                .bank(t.getBank())
                .baseRegionUid(t.getBaseRegionUid())
                .supAddress(t.getSupAddress())
                .supCode(t.getSupCode())
                .supGrade(t.getSupGrade())
                .supName(t.getSupName())
                .supOtherName(t.getSupOtherName())
                .companyType(t.getCompanyType())
                .supWebsite(t.getSupWebsite())
                .contactNumber(t.getContactNumber())
                .contactPerson(t.getContactPerson())
                .createTime(t.getCreateTime())
                .createUserUid(t.getCreateUserUid())
                .deleteFlag(t.getDeleteFlag())
                .email(t.getEmail())
                .establishTime(t.getEstablishTime())
                .factoryCode(t.getFactoryCode())
                .faxNumber(t.getFaxNumber())
                .legalPerson(t.getLegalPerson())
                .modifyTime(t.getModifyTime())
                .modifyUserUid(t.getModifyUserUid())
                .objuid(t.getObjuid())
                .region(baseRegionDTO)
                .remark(t.getRemark())
                .taxNumber(t.getTaxNumber())
                .contacts(baseContactVOS)
                .regionName(t.getRegion() == null ? null : t.getRegion().getRegionName())
                .build();
    }

    public static SupBasePartVO supBasePartDTO2VO(SupBasePartDTO t) {
        if (t == null) {
            return null;
        } else {
            SupBaseVO supBaseVO = supBaseDTO2VO(t.getSupBase());
            PartModelVO partModel = partModelDTO2VO(t.getPartModel());
            String showName = "";
            if (supBaseVO != null) {
                showName += supBaseVO.getSupName();
            }
            if (partModel != null) {
                showName += "-" + partModel.getPartName();
            }
            return SupBasePartVO.builder()
                    .partModelUid(t.getPartModelUid())
                    .createTime(t.getCreateTime())
                    .createUserUid(t.getCreateUserUid())
                    .supBaseUid(t.getSupBaseUid())
                    .deleteFlag(t.getDeleteFlag())
                    .factoryCode(t.getFactoryCode())
                    .modifyTime(t.getModifyTime())
                    .modifyUserUid(t.getModifyUserUid())
                    .objuid(t.getObjuid())
                    .remark(t.getRemark())
                    .supBase(supBaseVO)
                    .partModel(partModel)
                    .showName(showName)
                    .build();
        }
    }

    public static SupBasePartDTO supBasePartDO2DTO(SupBasePartDO t) {
        if (t == null) {
            return null;
        } else {
            SupBaseDTO supBaseDTO = supBaseDO2DTO(t.getSupBase());
            PartModelDTO partModel = partModelDO2DTO(t.getPartModel());
            return SupBasePartDTO.builder()
                    .partModelUid(t.getPartModelUid())
                    .createTime(t.getCreateTime())
                    .createUserUid(t.getCreateUserUid())
                    .supBaseUid(t.getSupBaseUid())
                    .deleteFlag(t.getDeleteFlag())
                    .factoryCode(t.getFactoryCode())
                    .modifyTime(t.getModifyTime())
                    .modifyUserUid(t.getModifyUserUid())
                    .objuid(t.getObjuid())
                    .remark(t.getRemark())
                    .supBase(supBaseDTO)
                    .partModel(partModel)
                    .build();
        }
    }

    public static StkTypeDTO stkTypeDO2DTO(StkType t) {
        if (t == null) {
            return null;
        }
        return StkTypeDTO.builder()
                .cTime(t.getcTime() == null ? null : DateUtils.asLocalDateTime(t.getcTime()))
                .cUserUid(t.getcUserUid())
                .delFlag(t.getDelFlag() == null ? null : t.getDelFlag() == 0 ? false : true)
                .mTime(t.getmTime() == null ? null : DateUtils.asLocalDateTime(t.getmTime()))
                .mUserUid(t.getmUserUid())
                .objuid(t.getObjuid())
                .remark(t.getRemark())
                .stkName(t.getStkName())
                .build();
    }
    public static StkTypeVO stkTypeDTO2VO(StkTypeDTO t) {
        if (t == null) {
            return null;
        }
        return StkTypeVO.builder()
                .cTime(t.getCTime())
                .cUserUid(t.getCUserUid())
                .delFlag(t.getDelFlag())
                .mTime(t.getMTime())
                .mUserUid(t.getMUserUid())
                .objuid(t.getObjuid())
                .remark(t.getRemark())
                .stkName(t.getStkName())
                .build();
    }

    public static StkMainDTO stkMainDO2DTO(StkMain t) {
        if (t == null) {
            return null;
        }
        return StkMainDTO.builder()
                .company(t.getCompany())
                .cTime(t.getcTime() == null ? null : DateUtils.asLocalDateTime(t.getcTime()))
                .cUserUid(t.getcUserUid())
                .delFlag(t.getDelFlag() == null ? null : t.getDelFlag() == 0 ? false : true)
                .mTime(t.getmTime() == null ? null : DateUtils.asLocalDateTime(t.getmTime()))
                .mUserUid(t.getmUserUid())
                .objuid(t.getObjuid())
                .dept(t.getDept())
                .location(t.getLocation())
                .remark(t.getRemark())
                .stkName(t.getStkName())
                .stkTypeUid(t.getStkTypeUid())
                .stkType(stkTypeDO2DTO(t.getStkType()))
                .build();
    }
    public static StkMainVO stkMainDTO2VO(StkMainDTO t) {
        if (t == null) {
            return null;
        }
        return StkMainVO.builder()
                .company(t.getCompany())
                .cTime(t.getCTime())
                .cUserUid(t.getCUserUid())
                .delFlag(t.getDelFlag())
                .mTime(t.getMTime())
                .mUserUid(t.getMUserUid())
                .objuid(t.getObjuid())
                .dept(t.getDept())
                .location(t.getLocation())
                .remark(t.getRemark())
                .stkName(t.getStkName())
                .stkTypeUid(t.getStkTypeUid())
                .stkType(stkTypeDTO2VO(t.getStkType()))
                .build();
    }
}
